// let ajaxURL = 'http://192.168.0.161:8808'
// let ajaxURL = 'http://192.168.0.161:8889'
let ajaxURL = 'http://d.lohand.com:8808'
// let ajaxURL = 'http://d.lohand.com:8889'
export default function request(url, method, data, beg = false) {
  return new Promise((resolve, reject) => {
    dd.httpRequest({
      url: ajaxURL + (url || ''),
      method: method || 'GET',
      headers: {
        'content-type': method == 'GET' ? 'application/json' : beg ? 'application/json' : 'application/x-www-form-urlencoded',
        'Accept': 'application/json'
      },
      dataType: 'json',
      data: data,
      success: res => {
        if (res.data.result === 'error' && res.data.status != 400) {
          // 错误提示
          dd.alert({
            title: '错误提示',
            content: res.data.msg
          });
          return reject(res.data)
        }

        if (res.data.result === 'success') {
          console.log('22222222222');
          // 成功提示
        }
        resolve(res.data)
      },
      fail: err => {
        reject(false)
      }
    })
  }).catch((e) => { })
}